package top.oneit.jdownload.test;

import com.jfoenix.controls.JFXTextField;
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.net.URL;

/**
 * @author lingkang
 */
public class TextField01 extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        // 加载 xml
        URL resource = getClass().getResource("/fxml/test/TextField.fxml");
        StackPane load = FXMLLoader.load(resource);
        Node lookup = load.lookup("#validatedText");
        JFXTextField field = (JFXTextField) lookup;
        field.focusedProperty().addListener((o, oldVal, newVal) -> {
            if (!newVal) {
                field.validate();
            }
        });

        primaryStage.setScene(new Scene(load));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}